//
//  AsyncTaskTrigger.h
//  AsyncTaskTrigger
//
//  Created by zhouzuosong on 2020/9/17.
//

#import <Foundation/Foundation.h>
#import "AsyncTask.h"
#import "AsyncTaskItem.h"



@interface AsyncTaskTrigger : NSObject

+ (instancetype)shareTrigger;

#pragma mark - 无Handler

/// 添加任务 带completBlock
/// @param actionBlock 任务事件
/// @param asyncType 异步类型 串行 还是 并行
/// @param groupKey 任务组Key
/// @param completBlock (同步部分)任务完成后的回调
- (void)addTaskAction:(LXTaskActionBlock)actionBlock
            asyncType:(LXTaskAsyncType)asyncType
             groupKey:(NSString *)groupKey
         completBlock:(LXTaskActionBlock)completBlock;

/// 添加任务
/// @param actionBlock 任务事件
/// @param asyncType 异步类型 串行 还是 并行
/// @param groupKey 任务组Key
- (void)addTaskAction:(LXTaskActionBlock)actionBlock
            asyncType:(LXTaskAsyncType)asyncType
             groupKey:(NSString *)groupKey;

/// 添加任务
/// @param actionBlock 任务事件
/// @param groupKey 任务组Key
- (void)addTaskAction:(LXTaskActionBlock)actionBlock
             groupKey:(NSString *)groupKey;

#pragma mark - Handler

/// 添加任务 带 completBlock
/// @param actionBlock 任务事件
/// @param asyncType 异步类型 串行 还是 并行
/// @param groupKey 任务组Key
/// @param completBlock (同步部分)任务完成后的回调
- (void)addTaskHandlerAction:(LXSemaphoreBlock)actionBlock
            asyncType:(LXTaskAsyncType)asyncType
             groupKey:(NSString *)groupKey
         completBlock:(LXTaskActionBlock)completBlock;

/// 添加任务
/// @param actionBlock 任务事件
/// @param asyncType 异步类型 串行 还是 并行
/// @param groupKey 任务组Key
- (void)addTaskHandlerAction:(LXSemaphoreBlock)actionBlock
            asyncType:(LXTaskAsyncType)asyncType
             groupKey:(NSString *)groupKey;
/// 添加任务
/// @param actionBlock 任务事件
/// @param groupKey 任务组Key
- (void)addTaskHandlerAction:(LXSemaphoreBlock)actionBlock groupKey:(NSString *)groupKey;

#pragma mark - 任务组

/// 准备初始化任务组
/// @param asyncType 异步类型 串行 还是 并行
/// @param groupKey 任务组Key
- (void)prepareTaskGroupWithAsyncType:(LXTaskAsyncType)asyncType groupKey:(NSString *)groupKey;

/// 清理任务组
/// @param asyncType 异步类型
/// @param groupKey 任务组Key
- (void)cleanTaskGroupWithAsyncType:(LXTaskAsyncType)asyncType groupKey:(NSString *)groupKey;

/// 开启某个任务组的任务
/// @param groupKey 任务组Key
/// @param completBlock 指定任务组完成的回调
- (void)startTaskActionWithGroupKey:(NSString *)groupKey
                       completBlock:(LXTaskActionBlock)completBlock;

/// 向指定任务组发送信号量 以疏通线程
/// @param groupKey 任务组Key】
- (void)sendSemaphoreToGroupKey:(NSString *)groupKey;

@end


